/*
 * cuda_rc4.cu
 *
 *  Created on: 13.06.2013
 *      Author: Eros
 */

#include <cuda.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

__global__ void RC4(unsigned char* x, unsigned char* y);

int main(int argc, char** argv)
{
	const int N = 1;
	unsigned char* a = (unsigned char*)argv[1];
	unsigned char b[256];
	unsigned char *b_cud, *a_cud;
	cudaMalloc((void**)&a_cud, 256*sizeof(char));
	cudaMalloc((void**)&b_cud, 256*sizeof(char));
	cudaMemcpy(a_cud, a, 256*sizeof(char),  cudaMemcpyHostToDevice);
	int block_size = 4;
	int n_blocks = N/block_size + (N%block_size == 0 ? 0:1);
	RC4<<<1, block_size>>>(a_cud, b_cud);
	cudaMemcpy(b, b_cud, 256*sizeof(char), cudaMemcpyDeviceToHost);
	printf("%s\n", b);
	return 0;
}

__global__ void RC4(unsigned char* x, unsigned char* y)
{
	y[0] = x[0];
	y[1] = 'l';
	y[2] = 'k';
	y[3] = '\0';
}
